package com.principle.inversion.improve;

//方式1：通过接口传递实现依赖
//开关的接口
interface IOperAndClose {
    public void open(ITV tv); //抽象方法,接收接口
}

interface ITV { //ITV接口
    public void play();
}

//方式2:通过构造方法传递依赖
interface IOpenAndClose {
    public void open(); //抽象方法
}

interface ITVS {
    public void play();
}


//方式3:通过setter方法传递
interface IOpenAndCloses {
    public void open(); //抽象方法

    public void setTvses(ITVSES itv);
}

interface ITVSES { //ITV接口
    public void play();
}

/**
 * @author xuehu
 * @date 2020/12/7 11:06
 */

public class DependencyPass {

    public static void main(String[] args) {

    }

}

//实现接口
class OpenAndClose implements IOperAndClose {

    @Override
    public void open(ITV tv) {
        tv.play();
    }
}

class OpenAndCloses implements IOpenAndClose {

    public ITVS tvs;

    public OpenAndCloses(ITVS itvs) {
        this.tvs = itvs;
    }

    @Override
    public void open() {
        this.tvs.play();
    }
}

class OpenAndClosess implements IOpenAndCloses {

    private ITVSES itvses;

    @Override
    public void open() {
        this.itvses.play();
    }

    @Override
    public void setTvses(ITVSES itvses) {
        this.itvses = itvses;

    }
}


